﻿// <copyright file="ProductFilter.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2009-07-20</date>
// <summary>ProductFilter.cs</summary>

namespace BestBuy
{
    using System.ComponentModel;

    /// <summary>
    /// Product Filter for querying BestBuy products
    /// </summary>
    public class ProductFilter : INotifyPropertyChanged
    {
        /// <summary>
        /// the attribute name
        /// </summary>
        private string attribute;

        /// <summary>
        /// the filter operator
        /// </summary>
        private string filterOperator;

        /// <summary>
        /// the operator value
        /// </summary>
        private string operatorValue;

        #region INotifyPropertyChanged Members

        /// <summary>
        /// Property changed event handler
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        /// <summary>
        /// Gets or sets the Attribute name
        /// </summary>
        public string Attribute
        {
            get
            {
                return this.attribute;
            }

            set
            {
                if (this.attribute != value)
                {
                    this.attribute = value;

                    this.TriggerPropertyChanged("Attribute");
                }
            }
        }

        /// <summary>
        /// Gets or sets the operator
        /// </summary>
        public string Operator
        {
            get
            {
                return this.filterOperator;
            }

            set
            {
                if (this.filterOperator != value)
                {
                    this.filterOperator = value;

                    this.TriggerPropertyChanged("Operator");
                }
            }
        }

        /// <summary>
        /// Gets or sets the filter value
        /// </summary>
        public string Value
        {
            get
            {
                return this.operatorValue;
            }

            set
            {
                if (this.operatorValue != value)
                {
                    this.operatorValue = value;

                    this.TriggerPropertyChanged("Value");
                }
            }
        }

        /// <summary>
        /// Trigger the property changed notification
        /// </summary>
        /// <param name="propertyName">the property name</param>
        private void TriggerPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
